class Solution {
public:
    int findMin(vector<int>& nums) {
        int left = 0;
        int right = nums.size() - 1;
        int n = nums.size();
        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (nums[mid] > nums[n - 1])
            {
                left = mid + 1;
            }
            else if (nums[mid] <= nums[n - 1])
            {
                right = mid;
            }
        }
        return nums[right];
    }
};